/**
 * util-lang.js - The minimal language enhancement
 */
function isType(type) {
  return function(obj) {
    return {}.toString.call(obj) == "[object " + type + "]"
  }
}

//计数功能
let _cid = 0
function cid() {
  return _cid++
}


function getElementLeft(element){
  var actualLeft = element.offsetLeft;
  var current = element.offsetParent;

  while (current !== null){
    actualLeft += current.offsetLeft;
    current = current.offsetParent;
  }

  return actualLeft;
}

function getElementTop(element){
  var actualTop = element.offsetTop;
  var current = element.offsetParent;

  while (current !== null){
    actualTop += current.offsetTop;
    current = current.offsetParent;
  }

  return actualTop;
}


export default{
  isObject : isType("Object"),
  isString: isType("String"),
  isArray : Array.isArray || isType("Array"),
  isFunction : isType("Function"),
  isUndefined : isType("Undefined"),
  getElementLeft: getElementLeft,
  getElementTop: getElementTop,
  "cid": cid,
}
